<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
</head>
<body>
<div onmouseover="overfn()" onmouseout="outfn()"
onmousedown="downfn()" onmouseup="upfn()"
onmousemove="movefn()"></div>
<input type="text" onkeydown="keydownfn()" onkeyup="keyupfn()"
        onkeypress="pressfn()">
<script>
    //键盘事件
    /*按下任何键时触发*/
    function keydownfn() {
        console.log("键盘按下 按键编码="+event.keyCode)
    }
    function keyupfn() {
        console.log("键盘抬起 字符="+String.fromCharCode(event.keyCode))
    }
     /* 按下了非功能键时触发*/
    function pressfn() {
        console.log("按下了内容")
    }





    //鼠标事件
    function downfn() {
        console.log("鼠标按下！")
    }
    function upfn() {
        console.log("鼠标抬起！")
    }
    function movefn() {
        console.log("鼠标移动！")
    }
    function overfn() {
        console.log("鼠标移入！")
    }
    function outfn() {
        console.log("鼠标移出！")
    }
</script>
</body>
</html>